package com.sunny.ihealth;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import com.jaeger.library.StatusBarUtil;

/**
 * Activity基类，初始化一些功能
 * Created by Sunny  An on 2016/5/14.
 */
public class BaseActivity extends AppCompatActivity {

    private Toolbar toolbar;


    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
    }

    /**
     * 设置Toolbar标题，返回按钮
     *
     * @param title
     */
    public void setToolbar(String title) {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        if (toolbar != null) {
            toolbar.setTitle(title);
            setSupportActionBar(toolbar);
            ActionBar actionBar = getSupportActionBar();
            if (actionBar != null) {
                actionBar.setHomeButtonEnabled(true);
                actionBar.setDisplayHomeAsUpEnabled(true);
            }
        }
    }

    /**
     * 获取toolbar
     *
     * @return
     */
    public Toolbar getToolbar() {
        return toolbar;
    }


    /**
     * 设置状态栏的颜色
     */
    public void setStatusBarColor() {
        StatusBarUtil.setColorNoTranslucent(this, getResources().getColor(R.color.colorPrimaryDark));
    }
}
